#ifndef __GPRS_H__
#define __GPRS_H__
#include "rtthread.h"


typedef enum
{
	GSM_SIM800C = 1,
	GSM_AIR208S = 2
}GSMTypeDef;

typedef enum
{
	GSM_IS_WORK = (0x01 << 0),//GSM工作
	GSM_IS_CONN = (0X01 << 1),//GSM链接网络
}GSMWorkStatusDef;

typedef enum
{
  AT,
	AT_CGMM,
  AT_CPIN,
  AT_COPS,
  AT_CSQ,
  AT_CGDCONT,
  AT_CGATT,
  AT_CIPHEAD,
  AT_CIPSTART ,
  AT_CIPSEND,
  AT_CIPCLOSE,
  AT_CIPCSGP,
  AT_CIPSHUT,
  AT_CDNSORIP,
  AT_CPOWD,
  AT_CIURC,
  AT_CSTT,
  AT_CIICR,
  AT_CIPSTATUS,
  AT_CSTT1,
  AT_CIFSR,
  AT_CIPSENDMAX,
  AT_CGREG1,
  AT_CIPQSEND,
  AT_CIPQSEND0,
  AT_CGCLASS,
  AT_CLPORT,
  AT_CIPMUX,
  AT_IFC,
  AT_CIPPING,
  AT_CIPMODE0,
  AT_CIPMODE1,
  AT_EXITDAT,
  AT_ATO,
  AT_CGMSCLASS,
  AT_CIPCCFG,
}ATCmdDef;

#define GSM_READ_LEN                  (544)


typedef enum
{
  GPRS_Net_Connect = 1,
  GPRS_Net_Break,
  GPRS_Send_Http,
  GPRS_Interior_Http,
  GPRS_Init,
  GPRS_CSQ,
  GPRS_Close,
}GPRSCmdDef;

typedef struct 
{
  int cmd;
  int mode;
  unsigned char *sendbuf;
  unsigned char *recvbuf;//第一个字节存放发送结果
  long       recvSize; //接收到下
  rt_sem_t   *finsh;		
  void *data;         //某些命令下的特殊数据
}GPRSMailDef;


int gprs_thread_init(void);
rt_int8_t gprs_module_start(rt_int8_t *curCsq,rt_uint8_t mode);
void gprs_module_stop(void);
int gprs_module_uart_crl(rt_uint8_t value);
rt_int8_t gsm_gprs_connect(int cmd,char *url,int port,int wait);
rt_int16_t gsm_send_gprs(rt_uint8_t *data,rt_uint8_t *buf,rt_uint16_t *size,rt_uint32_t delay);
rt_int8_t gsm_send_gprs_OSPF(rt_uint8_t *sBuf,rt_uint16_t ssize,rt_uint8_t *rBuf,rt_uint16_t *rlen,rt_uint16_t delay);
int gsm_switch_cmd(rt_uint8_t mode,rt_uint8_t *rbuf);
rt_err_t gprs_connet_resend(rt_int8_t (*fun)(int ,char *,int ,int),int cmd,char *url,int port,int wait);
rt_int8_t rsend_gprs_data(rt_uint8_t *sBuf,rt_uint16_t ssize,rt_uint8_t *rBuf,rt_uint16_t *rlen,rt_uint16_t delay);


#endif
